package mybatis.test;

import mybatis.MyBatisUtils;
import mybatis.mapper.UserMapper;
import mybatis.pojo.User;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class addUsers {
    public static void main(String[] args) {
        // 获取SqlSession对象
        SqlSession sqlSession = MyBatisUtils.getSession();
        // 获取UserMapper
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        // 创建User对象
        User user1 = new User("zs", 18);
        User user2 = new User("ls", 18);
        User user3 = new User("ww", 18);
        List<User> users = List.of(user1, user2, user3);
        mapper.addUsers(users);
        sqlSession.commit();
        sqlSession.close();
    }
}
